package com.example.aspect;

import com.example.critic.CriticismEngine;

// 评论员切面
public aspect CriticAspect {

    private CriticismEngine criticismEngine;

    public CriticAspect(){

    }

    pointcut performance(): execution(* concert.Performance.perform(..));

    // 后置通知（包括返回通知和异常通知）
    after():performance(){
        System.out.println(criticismEngine.getCriticism());
    }

    after() returning() : performance(){
        System.out.println("表演结束了！");
    }

    after() throwing() : performance(){
        System.out.println("表演出现了异常！");
    }

    void around():performance(){
        System.out.println("大家安静一下，表演就要开始了！");
        proceed();
        System.out.println("表演结束，请大家有序退场！");
    }

    public void setCriticismEngine(CriticismEngine criticismEngine) {
        this.criticismEngine = criticismEngine;
    }
}
